package com.ktjiaoyu.t313.singleton;

/**
 * 饿汉式单例模式
 */
public class EagerSingleton {

    //1、在类内部创建对象
    private static EagerSingleton singleton = new EagerSingleton();

    //2、私有化构造方法，避免外部实例化该对象
    private EagerSingleton(){

    }

    //3、提供一个静态方法，供外部访问
    public static EagerSingleton getInstance(){

        return singleton;
    }

}
